package eraserhead.entity;

import java.util.HashMap;

/**
 * Class for an open Decision Lines Event
 * @author Quanquan
 * @author Greg
 */
public class OpenDecision extends Decision{
	HashMap<User, Line> userChoices = new HashMap<User, Line>();
	
	/**
	 * Creates a new {@link OpenDecision}
	 * @param numRounds Number of rounds
	 * @param numLines Number of lines/choices
	 */
	public OpenDecision(int numRounds, int numLines) {
		super(numRounds, numLines);
	}
	
	public boolean isOpen() {
		return true;
	}
	
	/*@Override
	public boolean isReady() {
		for (int u =0; u<users; u++) {
			if (lines.get(u).choice.length() == 0) {
				return false;
			}
		}
		return true;
	}*/
	
	/*@Override
	public boolean resetNumUsers(int i) {
		if (i >= 3) {
			numUsers = i;
			return true;
		} else {
			errorMsg = "Need more than 3 choices.";
			return false;
		}
	}*/
	
	@Override
	public void updateHashMap() {
		for (Line l : lines) {
			if (!userChoices.containsValue(l)) {
				userChoices.put(signedInAs, l);
				return;
			}
		}
	}
	
	@Override
	public boolean[] userGiveChoice() {
		boolean[] canEdit = new boolean[numUsers];
		int position = userPlacement;
		System.out.println("Position:  " + position);
		for(int i = 0; i < numUsers; i++) {
			canEdit[i] = (position == i);
		}
		return canEdit;
	}
}
